# 二叉树的最大深度
class Solution:
    def maxDepth(self, root: Optional[TreeNode]) -> int:
        if not root:
            return 0
        queue=[root]
        result=0
        while queue:
            result+=1
            layer=[]
            for node in queue:
                if node.left:
                    layer.append(node.left)
                if node.right:
                    layer.append(node.right)
            queue=layer
        return result

# 二叉树的右视图
class Solution:
    def rightSideView(self, root: Optional[TreeNode]) -> List[int]:
        if not root:
            return []
        queue=[root]
        result=[]
        while queue:
            result.append(queue[-1].val)
            layer=[]
            for node in queue:
                if node.left:
                    layer.append(node.left)
                if node.right:
                    layer.append(node.right)
            queue=layer
        return result
